from django.db import models


class CephCluster(models.Model):
    """
    ceph 集群配置信息
    """
    id = models.AutoField(primary_key=True)
    name = models.CharField(verbose_name='集群名称', max_length=50, unique=True, blank=False)
    cluster_name = models.CharField(verbose_name='CLUSTER_NAME配置名称', max_length=50, blank=False)
    user_name = models.CharField(verbose_name='用户名称(USER_NAME)', max_length=50, blank=False)
    disable_choice = models.BooleanField(verbose_name='禁用选择(DISABLE_CHOICE)', default=False,
                                         help_text="默认false, 如果为true则该ceph配置不启用")
    pool_names = models.JSONField(verbose_name='POOL存储池名称', blank=False, default=list,
                                  help_text="配置标准：[\"池名1\",\"池名2\" ...]")

    config = models.TextField(verbose_name='ceph集群配置文本', default='')
    config_file = models.CharField(max_length=200, editable=False, blank=True, verbose_name='配置文件保存路径',
                                   help_text="点击保存，配置文本会存储到这个文件, 此字段自动填充")
    keyring = models.TextField(verbose_name='ceph集群keyring文本')
    keyring_file = models.CharField(max_length=200, editable=False, blank=True, verbose_name='keyring文件保存路径',
                                    help_text="点击保存，keyring文本会存储到这个文件, 此字段自动填充")
    modified_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
    alias = models.CharField(verbose_name='CEPH集群配置别名', max_length=16, blank=False, default='default', unique=True)
    remarks = models.CharField(verbose_name='备注', max_length=255, blank=True, default='')

    class Meta:
        ordering = ('id',)
        verbose_name = 'CEPH集群'
        verbose_name_plural = 'CEPH集群'

    def __str__(self):
        return self.name






